﻿using System;
using System.Threading;
using System.Collections.Generic;
using System.Diagnostics;
using Axe.Logging;

namespace Axe.Workflow
{
    public enum ExecutionControllerCommand { Start, Stop, Suspend, Resume };
    public enum ExecutionControllerState { Running, Stopped, Paused};

    /// <summary>
    /// Indicates the way of task state changing.
    /// </summary>
    public enum ControllerStateChangeStyle
    {
        /// <summary>
        /// Caller task first changes self state, and only then it requests to change style
        /// of it's child tasks.
        /// </summary>
        CallerFirst,

        /// <summary>
        /// Caller task first changes child tasks state, and only after then it changes self state.
        /// </summary>
        DependentFirst
    };
    

    /// <summary>
    /// Controls execution on some kink of task.
    /// </summary>
    public interface ITask
    {
        /// <summary>
        /// Gets a value indicating whether this task is running.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is running; otherwise, <c>false</c>.
        /// </value>
        bool IsRunning { get; }

        /// <summary>
        /// Gets a value indicating whether this task is paused.
        /// </summary>
        /// <value><c>true</c> if this instance is paused; otherwise, <c>false</c>.</value>
        bool IsPaused { get; }

        /// <summary>
        /// Gets the newState of the current task.
        /// </summary>
        /// <value>The newState of the task.</value>
        ExecutionControllerState TaskState { get;}

        /// <summary>
        /// Gets or sets the name of the task.
        /// </summary>
        /// <value>The name of the task.</value>
        string TaskName { get; set; }

        /// <summary>
        /// Resumes execution.
        /// </summary>
        bool Resume();

        /// <summary>
        /// Starts execution.
        /// </summary>
        bool Start();

        /// <summary>
        /// Stops execution.
        /// </summary>
        bool Stop();

        /// <summary>
        /// Suspends execution.
        /// </summary>
        bool Suspend();
    }

    public interface ILoggingSupportTask : ITask
    {
        /// <summary>
        /// Gets the task log.
        /// </summary>
        /// <value>The task log.</value>
        ILogger TaskLog { get; }
    }

}
